<?php $newnum = $num+1; ?>
<?php echo select_tag('calories', objects_for_select($cals, 'getId', 'getName', '', array('include_blank' => true)), array('id' => 'cals-' . $num, 'onchange' => remote_function(array('update' => 'consist-' . $num, 'url' => 'calories/kcal', 'with' => "'calid=' + jQuery('#cals-$num').val()+'&num=$num'")) . '' . remote_function(array('update' => 'caloryRow-' . $num, 'url' => 'calories/newrow', 'with' => "'curnum=$num'", 'position' => 'after', 'condition' => "jQuery('#caloryRow-$newnum').length == 0")) . 'setTimeout(\'total()\',1200);')) ?>